import requests
import time

def get_pnumber():
    url = "http://api.fxhyd.cn/UserInterface.aspx?action=getmobile&token=014336905694d748cec5aeb75c4cc731e50af0a22601&itemid=995"
    pnumber = requests.get(url).text  #获得电话号码
    # print(pnumber[8:])
    return pnumber[8:]



def get_code(p):
    for i in range(6):
        curl = "http://api.fxhyd.cn/UserInterface.aspx?action=getsms&token=014336905694d748cec5aeb75c4cc731e50af0a22601&itemid=995&mobile={0}&release=1".format(p)
        print(curl)
        result = requests.get(curl).content.decode('utf-8')  #获取验证码
        print(result)
        time.sleep(10)
        if len(result)>4:
            return result[17:21]


if __name__ == "__main__":
    p=get_pnumber()
    print(p)
    time.sleep(10)
    print(get_code(p))
